package com.ljkj.lawyer.lawyer.controller;

import com.ljkj.lawyer.lawyer.common.MessageResult;
import com.ljkj.lawyer.lawyer.param.AddParam;
import com.ljkj.lawyer.lawyer.param.litigation.AddBrieflyParam;
import com.ljkj.lawyer.lawyer.param.litigation.AddOrUpdateCaseParam;
import com.ljkj.lawyer.lawyer.param.litigation.AddOrUpdateNoCaseParam;
import com.ljkj.lawyer.lawyer.service.CaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/lawyer/case")
public class CaseController {
    @Autowired
    private CaseService caseService;
     /**
     * 更新或者添加是案件
     */
    @PostMapping("/addOrUpdateLigationCase")
    public MessageResult addOrUpdateLigationCase(@RequestBody @Valid AddOrUpdateCaseParam addParam) {
        if(addParam.getCaseType() != 2 && addParam.getCaseType() != 1){
            return  MessageResult.error("案件类型错误");
        }
        return caseService.addOrUpdateLigationCase(addParam);
    }

    /**
     * 分页获取律师下所有的案件列表（时间倒序）
     *
     * */
    @GetMapping("/getLigationCasePageList")
    public MessageResult getLigationCasePageList(@RequestParam(value = "pageNum",defaultValue = "1")Integer pageNum,@RequestParam(value = "pageSize",defaultValue = "5")Integer pageSize,@RequestParam("memberId")Integer memberId) {
        return caseService.getLigationCasePageList(pageNum,pageSize,memberId);
    }

    /**
     * 根据id获取案件详情
     * */
    @GetMapping("/getLigationCaseById")
    public MessageResult getLigationCaseById(@RequestParam("id")Integer id) {
        return caseService.getCaseDetail(id);
    }

    /**
     * 根据id添加案件开庭简要
     * */
    @PostMapping("/addLigationCaseBriefly")
    public MessageResult addLigationCaseBriefly(@RequestBody AddBrieflyParam addBrieflyParam) {
        return caseService.addLigationCaseBriefly(addBrieflyParam);
    }


}